<script setup>
import { ref } from 'vue'
import { onLaunch, onShow, onLoad } from '@dcloudio/uni-app'
import { getHomeBannerAPI } from '@/api/home.js'
//引入props
const props = defineProps({
  distributionSite: {
    // 1 为首页 2 为分类页
    type: Number,
    default: 1,
  },
})
//请求数据初始化页面
const bannerList = ref([])
const getHomeBannerData = async () => {
  const res = await getHomeBannerAPI(props.distributionSite)
  bannerList.value = res.result
}
onLoad(async () => {
  await getHomeBannerData()
})

</script>

<template>
  <view>
    <swiper indicator-dots autoplay circular>
      <swiper-item v-for="item in bannerList">
        <image mode="aspectFill" :src="item.imgUrl" style="width: 100%" />
      </swiper-item>
    </swiper>
  </view>
</template>

<style lang="scss"></style>
